home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / prtrep51.zip / REPSRC.ZIP / REPDEM03.PAS < prev    next >
Pascal/Delphi Source File  |  1996-06-24  |  2KB  |  78 lines

  1. unit Repdem03;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   StdCtrls, Forms, DBCtrls, DB, DBGrids, Buttons, DBTables, Grids,
  8.   ExtCtrls, Printers, PrnGridR, Funcs, CB_Types;
  9.  
  10. type
  11.   Tdem03form = class(TForm)
  12.     DBGrid1: TDBGrid;
  13.     Panel1: TPanel;
  14.     DataSource1: TDataSource;
  15.     Panel2: TPanel;
  16.     Query1: TQuery;
  17.     Label1: TLabel;
  18.     Label2: TLabel;
  19.     Preview: TBitBtn;
  20.     Exit: TBitBtn;
  21.     Query1PartNo: TFloatField;
  22.     Query1VendorNo: TFloatField;
  23.     Query1Description: TStringField;
  24.     Query1OnHand: TFloatField;
  25.     Query1OnOrder: TFloatField;
  26.     Query1Cost: TCurrencyField;
  27.     Query1ListPrice: TCurrencyField;
  28.     Query1OnOrderValue: TCurrencyField;
  29.     Query1OnHandValue: TCurrencyField;
  30.     Label3: TLabel;
  31.     PrintGridReport1: TPrintGridReport;
  32.     procedure FormCreate(Sender: TObject);
  33.     procedure PreviewClick(Sender: TObject);
  34.     procedure Query1CalcFields(DataSet: TDataset);
  35.   private
  36.     { private declarations }
  37.   public
  38.   end;
  39.  
  40. var
  41.   dem03form: Tdem03form;
  42.  
  43. implementation
  44.  
  45. {$R *.DFM}
  46.  
  47. procedure Tdem03form.FormCreate(Sender: TObject);
  48. begin
  49.   Query1.Open;
  50.  
  51.   { SubTotals will be on field VenderNo}
  52.   PrintGridReport1.SetSubTotalField(1, 'VendorNo');
  53.  
  54.   { Do not total next 3 fields, but do all the rest  }
  55.   PrintGridReport1.SetPrintTotal('Cost', False);
  56.   PrintGridReport1.SetPrintTotal('ListPrice', False);
  57.   PrintGridReport1.SetPrintTotal('VenderNo', False);
  58. end;
  59.  
  60. procedure Tdem03form.PreviewClick(Sender: TObject);
  61. begin
  62.     { Force Orientation to Landscape }
  63.     PrintGridReport1.Orientation := Landscape;
  64.  
  65.    { and send query for preview }
  66.     PrintGridReport1.Execute;
  67.     Printer.Orientation := poPortrait;
  68. end;
  69.  
  70.  
  71. procedure Tdem03form.Query1CalcFields(DataSet: TDataset);
  72. begin
  73.     Query1OnOrderValue.Value := Query1OnOrder.Value*Query1Cost.Value;
  74.   Query1OnHandValue.Value := Query1Cost.Value*Query1OnHand.Value;
  75. end;
  76.  
  77.  
  78. end.